import React from 'react';
import {Card, Form, Input, InputNumber,Switch} from "antd";
import {Link,useParams} from "react-router-dom";
import LogFactory from "log/LogFactory";
import {SecurityMenu} from "type/SecurityMenu";
import TextArea from "antd/es/input/TextArea";
import {fetchUpdateData} from  "../../../redux/reducer/menuReducer";
import SelectEnhance from "common/select/SelectEnhance";
import FormEnhanceUpdate from "common/form/FormEnhanceUpdate";

const log = LogFactory.getLog("MenuUpdateComponent");
const MenuUpdateComponent = () => {

    const { menuId } = useParams() ;
    const [form] = Form.useForm<SecurityMenu>() ;

    return (
        <Card
            title={"菜单更新"}
            extra={<Link to={""}>菜单列表</Link>}
        >
            <FormEnhanceUpdate<SecurityMenu>
                updateId={menuId}
                dataUrl={"/manager/security-menu/" + menuId}
                submitText={"更新"}
                fetchData = {fetchUpdateData}
                form={form}
            >
                <SelectEnhance<SecurityMenu> form={form} rowKey={'path'} selectLabel={"父菜单"} selectName={"parentId"}/>
                <Form.Item<SecurityMenu> label="菜单路径" name={"path"}>
                    <Input />
                </Form.Item>
                <Form.Item<SecurityMenu> label="菜单标题" name={"label"}>
                    <Input />
                </Form.Item>
                <Form.Item<SecurityMenu> label="功能描述" name={"describe"}>
                    <Input />
                </Form.Item>
                <Form.Item<SecurityMenu> label="菜单图标" name={"icon"}>
                    <Input />
                </Form.Item>
                <Form.Item<SecurityMenu> label="子菜单" name={"last"}>
                    <Switch />
                </Form.Item>
                <Form.Item<SecurityMenu> label="是否显示" name={"show"}>
                    <Switch />
                </Form.Item>
                <Form.Item<SecurityMenu> name={"menuOrder"} label="菜单排序">
                    <InputNumber min={0}/>
                </Form.Item>
                <Form.Item<SecurityMenu> name={"order"} label="数据排序">
                    <InputNumber min={0}/>
                </Form.Item>
                <Form.Item<SecurityMenu> name={"remark"} label="备注信息">
                    <TextArea rows={5}/>
                </Form.Item>
            </FormEnhanceUpdate>
        </Card>
    );
};

export default MenuUpdateComponent;